package com.hdoit.kylin.web.baseInfo.providers;

import java.util.ArrayList;
import java.util.List;

import com.hdoit.kylin.logical.baseInfo.model.School;
import com.hdoit.kylin.logical.baseInfo.service.ISchoolService;
import com.tennetcn.common.aop.CommonApplicationContextUtil;
import com.tennetcn.common.enums.pub.YesOrNoInteger;
import com.tennetcn.common.message.ListItem;
import com.tennetcn.component.attribute.provider.ISingleOptionListProvider;
import com.tennetcn.web.cbase.providers.base.DataListProviderBase;

public class SchoolIdProvider extends DataListProviderBase implements ISingleOptionListProvider<ListItem> {

	@Override
	public List<ListItem> getDataList(Object viewData) {
		List<School> schools = getSchoolId();
		if(schools==null||schools.size()<=0){
			return null;
		}
		dataList=new ArrayList<ListItem>();
		ListItem listItem=null;
		for (School school : schools) {
			listItem=new ListItem();
			listItem.setText(school.getSchoolName());
			listItem.setValue(school.getSchoolId());
			
			dataList.add(listItem);
		}
		return dataList;
	}

	private List<School> getSchoolId() {
		ISchoolService schoolService=CommonApplicationContextUtil.getCurrentContext().getBean(ISchoolService.class);
		return schoolService.queryList(YesOrNoInteger.no);
	}

}
